package com.xiaodao.service;

import com.xiaodao.api.BookApi;
import com.xiaodao.entity.Book;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.ValueConstants;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;

/**
 * Created by xiaodao
 * date: 2019/7/17
 */
@RestController
@RequestMapping("book")
public class BookServiceImpl implements BookApi {
    @GetMapping(value = "list")
    @Override
    public List<Book> findList() {
        try {
            TimeUnit.SECONDS.sleep(6);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Book book =Book.builder().id(1).name("第一本书").build();
        System.out.println(book);
       List<Book> list =  new  CopyOnWriteArrayList<>();
       list.add(book);
       return list;
    }


}
